<?php
require_once '../utils/common.php';
require_once '../Config.php';
$conn = mysql_connect ( host, username, password );
if (! $conn) {
	die ( "连接失败" . mysql_error () );
}
mysql_select_db ( db, $conn );
$flag = $_REQUEST['flag'];
if($flag == "add"){
	$qq = $_REQUEST['qq'];
	$name = $_REQUEST['name'];
	$tel = $_REQUEST['tel'];
	$sql = "set names utf8";
	mysql_query($sql);
	$sql = "insert into j_tab_kefu(qq, name, tel) values ('".$qq."','".$name."','".$tel."')";
	mysql_query($sql);
	mysql_close($conn);
	echo "<script>alert('添加成功!');self.location='KefuManager.php';</script>";
}else if($flag == 'del'){
	$id = $_REQUEST['id'];
	$sql = "delete from j_tab_kefu where id=".$id;
	mysql_query($sql);
	mysql_close($conn);
	echo "<script language=\"JavaScript\">\r\n";
	echo " alert(\"删除成功\");\r\n";
	echo " history.back();\r\n";
	echo "</script>";
	exit;
}else if($flag == 'update'){
	$id = $_REQUEST['id'];
	$qq = $_REQUEST['qq'];
	$name = $_REQUEST['name'];
	$tel = $_REQUEST['tel'];
	$sql = "set names utf8";
	mysql_query($sql);
		$sql = "update j_tab_kefu set qq='".$qq."',name='".$name."',tel='".$tel."' where id=".$id;
	
	mysql_query($sql);
	mysql_close($conn);
	echo "<script>alert('修改成功!');self.location='KefuManager.php';</script>";
}



?>